package com.lm.ffmpeg.controller;

import com.lm.ffmpeg.util.FFmpegUtil;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ffmpeg")
public class FFmpegController {

    @GetMapping("/screenshot")
    public String screenshot(@RequestParam String input, @RequestParam String output) {
        try {
            String cmd = String.format("ffmpeg -i %s -ss 00:00:02 -vframes 1 %s", input, output);
            FFmpegUtil.executeCommand(cmd);
            return "截图成功，输出文件：" + output;
        } catch (Exception e) {
            return "截图失败：" + e.getMessage();
        }
    }
}